//
//  OMOrderRefundDetailTableCell.m
//  OMENGO_NEW
//
//  Created by 梁尚嘉 on 2017/5/16.
//  Copyright © 2017年 Kamfat. All rights reserved.
//

#import "OMOrderRefundDetailTableCell.h"
#import "OMOrderRefundDetail.h"
@interface OMOrderRefundDetailTableCell ()
@property (nonatomic, strong) UILabel *snLabel;
@property (nonatomic, strong) UILabel *snDetailLabel;
@property (nonatomic, strong) UILabel *timeLabel;
@property (nonatomic, strong) UILabel *timeDetailLabel;
@property (nonatomic, strong) UILabel *reasonLabel;
@property (nonatomic, strong) UILabel *reasonDetailLabel;
@property (nonatomic, strong) UILabel *paymentLabel;
@property (nonatomic, strong) UILabel *paymentDetailLabel;
@property (nonatomic, strong) UILabel *periodicLabel;
@property (nonatomic, strong) UILabel *periodicDetailLabel;
@property (nonatomic, strong) UIButton *periodicDetailIV;

@property (nonatomic, strong) UILabel *refundLabel;
@property (nonatomic, strong) UILabel *refundDetailLabel;
@property (nonatomic, strong) UIButton *refundDetailIV;
@end

@implementation OMOrderRefundDetailTableCell

- (void)configure
{
    UIColor *elementColor = HEXCOLOR(@"969696");
    UIColor *detailColor = SM_blackColor;
    UIFont *font = SM_CFont(30);
    [super configure];
    _snLabel = [UILabel new];
    _snLabel.textColor = elementColor;
    _snLabel.font = font;
    _snLabel.text = @"订单编号";
    [self.contentView addSubview:_snLabel];
    [_snLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(SM_SIZE(30)));
        make.top.equalTo(@(SM_SIZE(40)));
    }];

    _timeLabel = [UILabel new];
    _timeLabel.textColor = elementColor;
    _timeLabel.font = font;
    _timeLabel.text = @"申请日期";
    [self.contentView addSubview:_timeLabel];
    [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_snLabel.mas_left);
        make.top.equalTo(_snLabel.mas_bottom).offset(SM_SIZE(25));
    }];

    _reasonLabel = [UILabel new];
    _reasonLabel.textColor = elementColor;
    _reasonLabel.font = font;
    _reasonLabel.text = @"退款原因";
    [self.contentView addSubview:_reasonLabel];
    [_reasonLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_snLabel.mas_left);
        make.top.equalTo(_timeLabel.mas_bottom).offset(SM_SIZE(25));
    }];


    _paymentLabel = [UILabel new];
    _paymentLabel.textColor = elementColor;
    _paymentLabel.font = font;
    _paymentLabel.text = @"付款方式";
    [self.contentView addSubview:_paymentLabel];
    [_paymentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_snLabel.mas_left);
        make.top.equalTo(_reasonLabel.mas_bottom).offset(SM_SIZE(25));
    }];


    _periodicLabel = [UILabel new];
    _periodicLabel.textColor = elementColor;
    _periodicLabel.font = font;
    _periodicLabel.text = @"退款周期";
    [self.contentView addSubview:_periodicLabel];
    [_periodicLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_snLabel.mas_left);
        make.top.equalTo(_paymentLabel.mas_bottom).offset(SM_SIZE(25));
    }];


    _refundLabel = [UILabel new];
    _refundLabel.textColor = elementColor;
    _refundLabel.font = font;
    _refundLabel.text = @"退款方式";
    [self.contentView addSubview:_refundLabel];
    [_refundLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_snLabel.mas_left);
        make.top.equalTo(_periodicLabel.mas_bottom).offset(SM_SIZE(25));
    }];

    _snDetailLabel = [UILabel new];
    _snDetailLabel.textColor = detailColor;
    _snDetailLabel.font = font;
    _snDetailLabel.text = @"8797 8884 285";
    [self.contentView addSubview:_snDetailLabel];
    [_snDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(SM_SIZE(200)));
        make.top.equalTo(self.snLabel.mas_top);
    }];

    _timeDetailLabel = [UILabel new];
    _timeDetailLabel.textColor = detailColor;
    _timeDetailLabel.font = font;
    _timeDetailLabel.text = @"商品选错了";
    [self.contentView addSubview:_timeDetailLabel];
    [_timeDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.snDetailLabel.mas_left);
        make.top.equalTo(self.timeLabel.mas_top);
    }];

    _reasonDetailLabel = [UILabel new];
    _reasonDetailLabel.textColor = detailColor;
    _reasonDetailLabel.font = font;
    _reasonDetailLabel.text = @"商品选错了";
    [self.contentView addSubview:_reasonDetailLabel];
    [_reasonDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.snDetailLabel.mas_left);
        make.top.equalTo(self.reasonLabel.mas_top);
    }];

    _paymentDetailLabel = [UILabel new];
    _paymentDetailLabel.textColor = detailColor;
    _paymentDetailLabel.font = font;
    _paymentDetailLabel.text = @"支付宝";
    [self.contentView addSubview:_paymentDetailLabel];
    [_paymentDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.snDetailLabel.mas_left);
        make.top.equalTo(self.paymentLabel.mas_top);
    }];

    _periodicDetailLabel = [UILabel new];
    _periodicDetailLabel.textColor = detailColor;
    _periodicDetailLabel.font = font;
    _periodicDetailLabel.text = @"1-7个工作日";
    [self.contentView addSubview:_periodicDetailLabel];
    [_periodicDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.snDetailLabel.mas_left);
        make.top.equalTo(self.periodicLabel.mas_top);
    }];

    _periodicDetailIV = [[UIButton alloc]init];
    [_periodicDetailIV setImage:[UIImage imageNamed:@"ic_order_refund_help"] forState:UIControlStateNormal];
    [_periodicDetailIV addTarget:self action:@selector(periodicRuleTap:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:_periodicDetailIV];
    [_periodicDetailIV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.periodicDetailLabel.mas_right).offset(SM_SIZE(20));
        make.centerY.equalTo(self.periodicDetailLabel.mas_centerY);
    }];

    _refundDetailLabel = [UILabel new];
    _refundDetailLabel.textColor = detailColor;
    _refundDetailLabel.font = font;
    _refundDetailLabel.text = @"款项返回到您的付款账户";
    [self.contentView addSubview:_refundDetailLabel];
    [_refundDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.snDetailLabel.mas_left);
        make.top.equalTo(self.refundLabel.mas_top);
    }];

    _refundDetailIV = [[UIButton alloc]init];
    [_refundDetailIV setImage:[UIImage imageNamed:@"ic_order_refund_help"] forState:UIControlStateNormal];
    [self.contentView addSubview:_refundDetailIV];
    [_refundDetailIV addTarget:self action:@selector(refundRuleTap:) forControlEvents:UIControlEventTouchUpInside];
    [_refundDetailIV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.refundDetailLabel.mas_right).offset(SM_SIZE(20));
        make.centerY.equalTo(self.refundDetailLabel.mas_centerY);
    }];

    _periodicDetailIV.hidden = YES;
    _refundDetailIV.hidden = YES;
}

- (void)configureCellWithObj:(OMOrderRefundDetail *)detail
{
    self.snDetailLabel.text = detail.sn;
    self.reasonDetailLabel.text = detail.memo;
    self.paymentDetailLabel.text = detail.payment_method;
    self.timeDetailLabel.text = detail.create_date;
}

#pragma mark - Actions
- (void)refundRuleTap:(id)sender
{
    NaviPresent(@"BaseViewController", (@{@"title":@"退款方式规则",@"isPresented":@(YES)}));
}

- (void)periodicRuleTap:(id)sender
{
    NaviPresent(@"BaseViewController", (@{@"title":@"退款周期规则",@"isPresented":@(YES)}));
}


+ (CGFloat)cellHeight
{
    return SM_SIZE(400);
}
@end
